//package com.weseal.config;
//
//import com.weseal.utils.MasterRealm;
//import org.apache.shiro.realm.CachingRealm;
//import org.apache.shiro.realm.Realm;
//import org.apache.shiro.realm.text.IniRealm;
//import org.apache.shiro.spring.LifecycleBeanPostProcessor;
//import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
//import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
//import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
//import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
//import org.apache.shiro.web.mgt.WebSecurityManager;
//import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
//import org.springframework.beans.factory.annotation.Configurable;
//import org.springframework.beans.factory.config.MethodInvokingFactoryBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.DependsOn;
//
//import javax.servlet.Filter;
//import java.util.LinkedHashMap;
//import java.util.Map;
//
///**
// * @author weseal
// * @title
// * @description
// * @usage
// * @copyright Copyright 2014  rrmj Corporation. All rights reserved.
// * @company 上海众多美网络科技有限公司
// * @create 2017/10/30
// */
//
//
//public class ShiroConfig {
//
//	@Bean("realm")
//	public MasterRealm realm() {
//		return new MasterRealm();
//	}
//
//
//	@Bean
//	@DependsOn({"realm"})
//	public WebSecurityManager securityManager() {
//		DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//		securityManager.setRealm(realm());
//		return securityManager;
//	}
//
//	@Bean
//	public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
//		return new LifecycleBeanPostProcessor();
//	}
//
//
//	@Bean
//	@DependsOn("lifecycleBeanPostProcessor")
//	public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
//		return new DefaultAdvisorAutoProxyCreator();
//	}
//
//
//	/**
//	 * 开启aop注解
//	 *
//	 * @return
//	 */
//	@Bean
//	@DependsOn({"securityManager"})
//	public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor() {
//		AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
//		authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
//		return authorizationAttributeSourceAdvisor;
//	}
//
//
//	@Bean
//	public FormAuthenticationFilter formAuthenticationFilter() {
//		FormAuthenticationFilter formAuthenticationFilter = new FormAuthenticationFilter();
//		formAuthenticationFilter.setPasswordParam("password");
//		formAuthenticationFilter.setUsernameParam("userName");
//		formAuthenticationFilter.setLoginUrl("/login");
//		return formAuthenticationFilter;
//	}
//
//
//	@Bean(name = "shiroFilter")
//	public ShiroFilterFactoryBean shiroFilterFactoryBean() {
//		ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
//		shiroFilterFactoryBean.setSecurityManager(securityManager());
//		shiroFilterFactoryBean.setLoginUrl("/login");
//		shiroFilterFactoryBean.setUnauthorizedUrl("/unauthorized");
//		Map<String, Filter> filterMap = new LinkedHashMap<>();
//		filterMap.put("authc", formAuthenticationFilter());
//		shiroFilterFactoryBean.setFilters(filterMap);
//		Map<String, String> filterChainDefinitions = new LinkedHashMap<>();
//		filterChainDefinitions.put("/login", "authc");
//		filterChainDefinitions.put("/logout", "logout");
//		filterChainDefinitions.put("/unauthorized", "anon");
//		filterChainDefinitions.put("/static/*", "anon");
//		filterChainDefinitions.put("/**", "anon");
//		shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitions);
//		return shiroFilterFactoryBean;
//	}
//
//}
